package com.kingwang.training.designpattern.decorator;

import com.kingwang.training.designpattern.decorator.bo.Coffie;
import com.kingwang.training.designpattern.decorator.bo.Drinkable;
import com.kingwang.training.designpattern.decorator.bo.Milk;
import com.kingwang.training.designpattern.decorator.bo.Sugar;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 纯咖啡
        Drinkable coffie = new Coffie();

        // 加牛奶
        Drinkable milkCoffie = new Milk(coffie);

        // 加糖
        Drinkable sugarMilkCoffie = new Sugar(milkCoffie);

        // 加两份糖
        Drinkable doubleSugarMilkCoffie = new Sugar(sugarMilkCoffie);

        System.out.println(doubleSugarMilkCoffie.info() + "--价格是：" + doubleSugarMilkCoffie.cost());
    }
}
